﻿@using ZBJF.Warranty.BLL
@using ZBJF.Warranty.Common.Enums.Certificate
@using ZBJF.Warranty.Common.Enums.Data
@using ZBJF.Warranty.Common.Enums.InsuranceOrder
@using ZBJF.Warranty.Common.Enums.InsuranceWarranty
@using ZBJF.Warranty.Model
@using ZBJF.Warranty.WebProvider
@using EnumHelper = ZBJF.Warranty.Common.Common.EnumHelper
@model ZBJF.Warranty.Model.InsuranceWarrantyRecord
@{
    var canEdit = Model.Status < (byte)InsuranceWarrantyStatus.Processing;
    var parentCompany = ServiceFactory.InsuranceCompanyServiceInstance.GetCompanyByParentId(Model.InsuranceOrder.InsuranceCompanyID ?? 0) ?? new InsuranceCompany();
}
<h4>保单信息</h4>
<table class="table table-responsive table-bordered table-hover">
    <tr>
        <th class="w120">保险产品类别：</th>
        <td class="w-p25">@Html.DisplayFor(o => o.InsuranceOrder.InsuranceCategoryName)</td>
        <th class="w120">保险产品名称：</th>
        <td class="w-p25">@Html.DisplayFor(o => o.InsuranceOrder.ProductName)</td>
        <th class="w120">保单状态：</th>
        <td>@ZBJF.Warranty.Common.Common.EnumHelper.Instance.GetDescription(typeof(InsuranceOrderStatus), Model.InsuranceOrder.OrderStatus)</td>
    </tr>
    <tr>
        <th>第三方保单号：</th>
        <td>
            @if (canEdit && string.IsNullOrEmpty(Model.InsuranceOrder.ThirdOrderNO))
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.ThirdOrderNO, new { validate = "{required:true,messages:{required:'请输入第三方保单号！'}}" })
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.ThirdOrderNO)
            }
        </td>
        <th>承保公司：</th>
        <td>
            @if (canEdit && string.IsNullOrEmpty(Model.InsuranceOrder.InsuranceCompany))
            {
                @Html.TextBoxFor(m => m.InsuranceOrder.InsuranceCompany, new { validate = "{required:true,messages:{required:'请选择承保公司'}}", onfocus = "this.blur()", placeholder = "请选择承保公司分公司" })
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.InsuranceCompany)
            }
        </td>
        <th>承保公司分公司：</th>
        <td>
            @if (canEdit && (string.IsNullOrEmpty(Model.InsuranceOrder.InsuranceCompany) || string.IsNullOrEmpty(Model.InsuranceOrder.InsuranceCompanyBranch)))
            {
                @Html.TextBoxFor(m => m.InsuranceOrder.InsuranceCompanyBranch, new { validate = "{required:true,messages:{required:'请选择承保公司'}}", @readonly = "readonly", @class = "select-icon", onclick = "showLayerOpen('选择承保公司','/PubModelDialog/InsuranceCompanySelector?chkStyle=radio&textid=InsuranceOrder_InsuranceCompanyBranch&hiddenId=InsuranceOrder_InsuranceCompanyID','320px','60%')" })
                @Html.HiddenFor(m => m.InsuranceOrder.InsuranceCompanyID)
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.InsuranceCompanyBranch)
            }
        </td>
    </tr>
    <tr>
        <th>投保时间：</th>
        <td>
            @Model.InsuranceOrder.CreateOrderTime.ToString("yyyy-MM-dd")
        </td>
        <th>保险起期：</th>
        <td>
            @if (!Model.InsuranceOrder.EffectiveDate.HasValue && canEdit)
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.EffectiveDate, new { validate = "{required:true,messages:{required:'请选择保险起期！'}}", onclick = "WdatePicker()", @class = "Wdate" })
            }
            else
            {
                if (Model.InsuranceOrder.EffectiveDate.HasValue)
                {
                    @Model.InsuranceOrder.EffectiveDate.Value.ToString("yyyy-MM-dd")
                }
            }
        </td>
        <th>保险止期：</th>
        <td>
            @if (!Model.InsuranceOrder.ServiceEndTime.HasValue && canEdit)
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.ServiceEndTime, new { validate = "{required:true,messages:{required:'请选择保险止期！'}}", onclick = "WdatePicker()", @class = "Wdate" })
            }
            else
            {
                if (Model.InsuranceOrder.ServiceEndTime.HasValue)
                {
                    @Model.InsuranceOrder.ServiceEndTime.Value.ToString("yyyy-MM-dd")
                }
            }
        </td>
    </tr>
    <tr>
        <th>被保险人姓名：</th>
        <td>
            @if (canEdit && string.IsNullOrEmpty(Model.InsuranceOrder.UserName))
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.UserName, new { validate = "{required:true,messages:{required:'请输入被保险人姓名！'}}" })
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.UserName)
            }
        </td>
        <th>被保险人电话：</th>
        <td>
            @if (canEdit && string.IsNullOrEmpty(Model.InsuranceOrder.UserPhone))
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.UserPhone, new { validate = "{required:true,messages:{required:'请输入被保险人电话！'}}" })
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.UserPhone)
            }
        </td>
        <th>保额：</th>
        <td>
            @if (canEdit && !Model.InsuranceOrder.InsuredAmount.HasValue)
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.InsuredAmount, new { validate = "{required:true,number:true,messages:{required:'请输入保额！'}}", onkeyup = "onlyInputDecimal(this)" })
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.InsuredAmount)
            }
        </td>
    </tr>
    <tr>
        <th>被保险人证件类型：</th>
        <td>
            @if (Model.InsuranceOrder.CertificateType > 0 && !canEdit)
            {
                @Html.DropDownListFor(o => o.InsuranceOrder.CertificateType, ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(UserCertificateType)))
            }
            else
            {
                @EnumHelper.Instance.GetDescription(typeof(UserCertificateType), Model.InsuranceOrder.CertificateType)
            }
        </td>
        <th>被保险人证件号码：</th>
        <td>
            @if (canEdit && string.IsNullOrEmpty(Model.InsuranceOrder.CertificateNO))
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.CertificateNO, new { validate = "{required:true,messages:{required:'请输入被保险人证件号码！'}}" })
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.CertificateNO)
            }
        </td>
        <th>被保险设备类型：</th>
        <td>
            @if (Model.InsuranceOrder.DeviceType < 1 && canEdit)
            {
                @Html.DropDownListFor(o => o.InsuranceOrder.DeviceType, ConvertToSelector.Instance.EnumTypeConvertToSelectList(typeof(InsuranceOrderDeviceType)))
            }
            else
            {
                @EnumHelper.Instance.GetDescription(typeof(InsuranceOrderDeviceType), Model.InsuranceOrder.DeviceType)
            }
        </td>
    </tr>
    <tr>
        <th>设备识别码：</th>
        <td>
            @if (canEdit && string.IsNullOrEmpty(Model.InsuranceOrder.IMEI))
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.IMEI, new { validate = "{required:true,messages:{required:'请输入设备识别码！'}}" })
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.IMEI)
            }
        </td>
        <th>被保险设备品牌：</th>
        <td>
            @if (canEdit && !Model.InsuranceOrder.ProductBrandId.HasValue)
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.ProductBrandName, new { validate = "{required:true,messages:{required:'请输入被保险设备品牌！'}}", onfocus = "this.blur()" })
                @Html.HiddenFor(o => o.InsuranceOrder.ProductBrandId)
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.ProductBrandName)
            }
        </td>
        <th>被保险设备型号：</th>
        <td>
            @if (canEdit && !Model.InsuranceOrder.ProductModelId.HasValue)
            {
                @Html.TextBoxFor(o => o.InsuranceOrder.ProductModelName, new { validate = "{required:true,messages:{required:'请输入被保险设备型号！'}}", onfocus = "this.blur()" })
                @Html.HiddenFor(o => o.InsuranceOrder.ProductModelId)
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.ProductModelName)
            }
        </td>
    </tr>
    <tr>
        <th>型号代码</th>
        <td>
            @if (canEdit && !Model.InsuranceOrder.ProductModelId.HasValue)
            {
                @Html.TextBox("ModelCode", "", new { onfocus = "this.blur()" })
                <a href="javascript:void(0)" onclick="showLayerOpen('型号查询', '/PubModelDialog/ProductModelsSelector?modelCode=@(Model.InsuranceOrder.ProductModelId.HasValue ? Model.InsuranceOrder.ProductModels.ModelCode : "")', '300px', '260px')">点击查询</a>
            }
            else
            {
                @Html.DisplayFor(o => o.InsuranceOrder.ProductModels.ModelCode)
            }
        </td>
        <th></th>
        <td></td>
        <th></th>
        <td></td>
    </tr>
</table>
<script type="text/javascript">
    function setSelectedTreeNode(item, textid, hiddenId) {
        if (!item.ID) //双击 单个 否则是点击确定多个
            item = item[0];
        if (!item || item == "") {
            $("#" + hiddenId).val("");
            $("#" + textid).val("");
            $("#InsuranceOrder_InsuranceCompany").val("");
        } else {
            $("#" + hiddenId).val(item.ID);
            $("#" + textid).val(item.name);
            $("#InsuranceOrder_InsuranceCompany").val(item.ParentName);
        }
    }
    function setSelectModel(model) {
        $("#InsuranceOrder_ProductBrandId").val(model.BrandId);
        $("#InsuranceOrder_ProductBrandName").val(model.BrandName);
        $("#InsuranceOrder_ProductModelId").val(model.ID);
        $("#InsuranceOrder_ProductModelName").val(model.ModelName);
        $("#ModelCode").val(model.ModelCode);
    }
</script>